
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>帐号设置</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="fly,layui,前端社区">
  <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
  <link rel="stylesheet" href="../../static/res/layui/css/layui.css">
  <link rel="stylesheet" href="../../static/res/css/global.css">
</head>
<body>

<div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="/">
      <img src="../../static/res/images/logo.png" alt="layui">
    </a>
    <ul class="layui-nav fly-nav layui-hide-xs">
      <li class="layui-nav-item layui-this">
        <a href="/"><i class="iconfont icon-jiaoliu"></i>交流</a>
      </li>
      <li class="layui-nav-item">
        <a href="../case/case.html"><i class="iconfont icon-iconmingxinganli"></i>案例</a>
      </li>
      <li class="layui-nav-item">
        <a href="http://www.layui.com/" target="_blank"><i class="iconfont icon-ui"></i>框架</a>
      </li>
    </ul>

    <ul class="layui-nav fly-nav-user">
      <!-- 登入后的状态 -->
      <li class="layui-nav-item">
        <a class="fly-nav-avatar" href="javascript:;">
          <cite class="layui-hide-xs">{{user.nick_name}}</cite>
          <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：layui 作者"></i>
            {%if user.is_vip%}
          <i class="layui-badge fly-badge-vip layui-hide-xs">VIP{{user.is_vip}}</i>
            {%endif%}
          <img src="{{user.avatar_url}}">
        </a>
        <dl class="layui-nav-child">
          <dd><a href="/user/set"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
          <dd><a href="/user/message"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
          <dd><a href="/user/home?u={{user.id}}"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
          <hr style="margin: 5px 0;">
          <dd><a href="/user/logout" style="text-align: center;">退出</a></dd>
        </dl>
      </li>
    </ul>
  </div>
</div>

<div class="layui-container fly-marginTop fly-user-main">
  <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
    <li class="layui-nav-item">
      <a href="/user/home?u={{user.id}}">
        <i class="layui-icon">&#xe609;</i>
        我的主页
      </a>
    </li>
    <li class="layui-nav-item">
      <a href="/user/index">
        <i class="layui-icon">&#xe612;</i>
        用户中心
      </a>
    </li>
    <li class="layui-nav-item layui-this">
      <a href="/user/set">
        <i class="layui-icon">&#xe620;</i>
        基本设置
      </a>
    </li>
          <li class="layui-nav-item icon-tiezi">
      <a href="/user/user_message">
        <i class="layui-icon">&#xe621;</i>
        我的贴子
      </a>
    </li>
    <li class="layui-nav-item">
        <a href="/user/collect">
        <i class="layui-icon">&#xe600;</i>
        我的收藏
      </a>
    </li>
          <li class="layui-nav-item">
      <a href="/user/follow">
        <i class="layui-icon">&#xe654;</i>
        我的关注
      </a>
    </li>
           <li class="layui-nav-item">
      <a href="/user/fly_kiss">
        <i class="layui-icon">&#xe657;</i>
        飞吻商城
      </a>
    </li>
  </ul>

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>


  <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li class="layui-this" lay-id="info">我的资料</li>
        <li lay-id="avatar">头像</li>
        <li lay-id="pass">密码</li>

      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">
        <div class="layui-form layui-form-pane layui-tab-item layui-show">
          <form method="post">
            <div class="layui-form-item">
              <label for="L_email" class="layui-form-label">邮箱</label>
              <div class="layui-input-inline">
                <input type="text" id="L_email" name="email" style="cursor: not-allowed !important;" required lay-verify="email" autocomplete="off" value="{{user.email}}" class="layui-input  layui-word-aux" readonly>
              </div>
              <div class="layui-form-mid layui-word-aux">邮箱信息暂无法修改，请牢记您的邮箱</div>
            </div>
            <div class="layui-form-item">
              <label for="L_username" class="layui-form-label">昵称</label>
              <div class="layui-input-inline">
                <input type="text" id="L_username" name="username" required lay-verify="required" autocomplete="off" value="{{user.nick_name}}" class="layui-input">
              </div>
              <div class="layui-inline">
                <div class="layui-input-inline">
                    {% if user.gender == "MAN"%}
                  <input type="radio" class="gender" name="sex" value="MAN" checked title="男">
                  <input type="radio" class="gender" name="sex" value="WOMAN" title="女">
                    {%else%}
                    <input type="radio" class="gender" name="sex" value="MAN" title="男">
                  <input type="radio" class="gender" name="sex" value="WOMAN" checked  title="女">
                    {%endif%}
                </div>
              </div>
            </div>

            <div class="layui-form-item layui-form-text">
              <label for="L_sign" class="layui-form-label">签名</label>
              <div class="layui-input-block">
                  {%if user.signature %}
                 <textarea placeholder="{{user.signature}}" id="L_sign"  name="sign" autocomplete="off" class="layui-textarea" style="height: 80px;"></textarea>
                {%else%}
                <textarea placeholder="随便写些什么刷下存在感" id="L_sign"  name="sign" autocomplete="off" class="layui-textarea" style="height: 80px;"></textarea>
                {%endif%}
              </div>
            </div>
            <div class="layui-form-item">
              <input class="layui-btn" onclick="bbb()" style="width:120px;" value="确认修改" readonly>
            </div>
          </form></div>

          <div class="layui-form layui-form-pane layui-tab-item">
            <div class="layui-form-item">
              <div class="avatar-add">
                <p>建议尺寸168*168，支持jpg、png、gif，最大不能超过50KB</p>
                <button type="button" class="layui-btn upload-img">
                  <i class="layui-icon">&#xe67c;</i>上传头像
                </button>
                <img src="{{user.avatar_url}}">
                <span class="loading"></span>
              </div>
            </div>
          </div>

          <div class="layui-form layui-form-pane layui-tab-item">
            <form action="/user/repass" method="post">
              <div class="layui-form-item">
                <label for="L_nowpass" class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_nowpass" name="nowpass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="pass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div>
              </div>
              <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_repass" name="repass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div><div class="layui-form-mid layui-word-aux">重复新密码</div>
              </div>
              <div class="layui-form-item">
              <input class="layui-btn" onclick="aaa()" style="width:120px;" value="确认修改" readonly>

              </div>
            </form>
          </div>

          <div class="layui-form layui-form-pane layui-tab-item">

          </div>
        </div>

      </div>
  </div>
</div>

<div class="fly-footer">
  <p><a href="http://fly.layui.com/" target="_blank">Fly社区</a> 2017 &copy; <a href="http://www.layui.com/" target="_blank">layui.com 出品</a></p>

</div>

<script src="../../static/res/layui/layui.js"></script>
<script src="../../static/js/jquery-3.3.1.js"></script>
<script>
    function aaa(){
        var old_pwd = document.getElementById("L_nowpass").value;
        var pwd1 = document.getElementById("L_pass").value;
        var pwd2 = document.getElementById("L_repass").value;
        if (!old_pwd){
            alert("请输入旧密码");
            return ""
        }
        else if (!pwd1){
          alert("请输入新密码");
            return ""
        }
        else if (!pwd2){
               alert("请重复新密码");
            return ""
        }
        var params = {
                "old_pwd": old_pwd,
                "pwd1": pwd1,
                "pwd2": pwd2
            };
         $.ajax({
                url: "/user/repass",
                type: "post",
                data: JSON.stringify(params),
                contentType: "application/json",
                success: function (resp) {
                if (resp.status == "0") {
                    alert("修改成功");
                    location.href='http://www.tnan.top/user/set';
                }
                else  {
                    // 用户登录
                    alert(resp.msg);
                }
                }
            })
    }
    function bbb(){
        var email = document.getElementById("L_email").value;
        var user = document.getElementById("L_username").value;
        var sign = document.getElementById("L_sign").value;
        var gender = $(".gender:checked").val();
        var params = {
                "email": email,
                "username": user,
                "sign": sign,
                "gender":gender
            };
         $.ajax({
                url: "/user/set",
                type: "post",
                data: JSON.stringify(params),
                contentType: "application/json",
                success: function (resp) {
                if (resp.status == "0") {
                    alert("修改成功");
                    location.href='http://www.tnan.top/user/set';
                }
                else  {
                    // 用户登录
                    alert(resp.msg);
                }
                }
            })
    }
layui.cache.page = 'user';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '../../res/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  base: '../../static/res/mods/'
}).extend({
  fly: 'index'
}).use('fly');
</script>

</body>
</html>